package com.light.dp.flink.sink;

import com.alibaba.fastjson.JSONObject;
import com.light.dp.flink.config.dto.TableMapping;
import com.light.dp.flink.config.dto.TargetJDBCDatabaseConfig;
import com.light.dp.flink.dto.Column;
import com.light.dp.flink.dto.DataChangeInfo;
import com.light.dp.flink.dto.User;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;

import java.sql.*;
import java.util.List;

public class ClickHouseStockSink1 extends RichSinkFunction<DataChangeInfo> {
    private static final int MAX_RETRIES = 3;
    private Connection connection;
    private List<PreparedStatement> preparedStatements;
    private TargetJDBCDatabaseConfig targetConfig;
    private List<TableMapping> tableMappings;

    public ClickHouseStockSink1(TargetJDBCDatabaseConfig targetConfig, List<TableMapping> tableMappings) {
        this.targetConfig = targetConfig;
        this.tableMappings = tableMappings;
    }

    @Override
    public void open(Configuration parameters) throws Exception {
        super.open(parameters);
    }

    @Override
    public void invoke(DataChangeInfo value) throws Exception {
        for (Column column : value.getColumns()) {
            if ("id".equals(column.getName())){
                System.out.println("id：" + column.getValue());
            }
        }
    }
}